class BlockFactory { 
  int maxTypes = 7;
  
  Block createBlock(int type) {
    Block b;
    switch (type) {
      case -1:
        b = new BlockGeneric();
        break;
      case 0:
        b = new BlockA();
        break;
      case 1:
        b = new BlockB();
        break;
      case 2:
        b = new BlockF();
        break;
      case 3:
        b = new BlockH();
        break;
      case 4:
        b = new BlockI();
        break;
      case 5:
        b = new BlockL();
        break;
      case 6:
        b = new BlockX();
        break;
      default:
        return null;
    }
    b.type = type;
    return b;
  }
  
  Block createRandom() {
    return this.createBlock(int(random(this.maxTypes)));
  }
  
  Block createUniqueRandom(ArrayList<Block> blocks) {
    int uniqueType = -2;
    boolean unique = false;
    while (!unique) {
      unique = true;
      uniqueType = int(random(this.maxTypes));
      for (Block b : blocks) {
        if (b.type == uniqueType) {
          unique = false;
          break;
        }
      }
    }
    return this.createBlock(uniqueType);
  }
}

class BlockGeneric extends Block {
  BlockGeneric() {
    super();
  }
  
  void draw() {
    this.drawConvexHull();
  }
}

class BlockA extends Block {
  BlockA() {
    super();
    this.add(-19,-89);
    this.add(19,-89);
    this.add(-67,30);
    this.add(67,30);
    this.add(89,89);
    this.add(-89,89);
  }
  
  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("A", super.rectangle.c.x, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}

class BlockB extends Block {
  BlockB() {
    super();
    this.add(-75,-89);
    this.add(66,-45);
    this.add(-75,0);
    this.add(75,45);
    this.add(-75,89);
  }
  
  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("B", super.rectangle.c.x - 3, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}

class BlockF extends Block {
  BlockF() {
    super();
    this.add(-61,-89);
    this.add(61,-89);
    this.add(-61,0);
    this.add(50,0);
    this.add(-61,89);
  }
  
  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("F", super.rectangle.c.x - 3, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}

class BlockH extends Block {
  BlockH() {
    super();
    this.add(-71,-89);
    this.add(71,-89);
    this.add(-71,-5);
    this.add(71,-5);
    this.add(-71,89);
    this.add(71,89);
  }
  
  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("H", super.rectangle.c.x, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}

class BlockI extends Block {
  BlockI() {
    super();
    this.add(-18,-89);
    this.add(18,-89);
    this.add(-18,89);
    this.add(18,89);
  }
  
  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("I", super.rectangle.c.x, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}

class BlockL extends Block {
  BlockL() {
    super();
    this.add(-63, -89);
    this.add(-63, 89);
    this.add(63, 89);
  }

  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("L", super.rectangle.c.x - 6, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}

class BlockX extends Block {
  BlockX() {
    super();
    this.add(-79,-89);
    this.add(-37,-89);
    this.add(37,-89);
    this.add(79,-89);
    this.add(-79,89);
    this.add(-37,89);
    this.add(37,89);
    this.add(79,89);
  }
  
  void draw() {
    textAlign(CENTER, CENTER);
    textSize(250);
    text("X", super.rectangle.c.x, super.rectangle.c.y - 36);
    pushStyle();
    stroke(0);
    noFill();
    for (PVector v : super.vertices) {
      ellipse(v.x, v.y, 10, 10);
    }
    popStyle();
  }
}
